{% if page.post_list == "date" %}
<!-- list of articles: sort by date (by default) -->
<h1 class="loa">Post List, sorted by date</h1>
<table>
    <thead>
        <tr>
            <th> TITLE </th>
            <th> DATE </th>
            <th> CATEGORY </th>
        </tr>
    </thead>
    <tbody>
        {% for post in site.posts %}
        </tr>
        <td class="td_title"><a href="{{post.url}}">{{post.title}}</a></td>
        <td class="td_date">{{post.date | date: "%b %d, %y"}}</td>
        <td class="td_category">{{post.category}}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% elsif page.post_list == "category" %}
<!-- list of articles: sorted by category-->
<h1>Post List, sorted by Category</h1>
<table>
{% assign sorted_categories = site.categories | sort %}
{% for cate in sorted_categories %} 
{% capture cate_name %}
{{ cate[0] }}
{% endcapture %}
<table id="t_{{ cate_name | slugzie }}">
    <thead>
        <tr>
        <th id="cate_name"><i class="fa fa-tags"></i>{{ cate_name }}</th>
        <th></th>  
        </tr>
    </thead>
  <tbody>
    {% assign sorted_cate = {cate[1] | sort: 'title', 'last'} %}
    {% for post in sorted_cate %}
    <tr>
      <td class="td_title"><a href="{{post.url}}">{{ post.title }}</a></td>
      <td class="td_date">{{ post.date | date: "%Y/%m/%d" }}</td>
    </tr>
    {% endfor %}
  </tbody>
{% endfor %}
</table>
{% endif %}
